{% extends "site_base.html" %}

{% load i18n %}

{% block head_title %}{% endblock %}

{% block extra_head_base %}
	{% block extra_head %}
		<!-- Place this tag in your head or just before your close body tag -->
		<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
	{% endblock %}
{% endblock %}

{% block body_class %}
	{% if current_article %}
		
	{% else %}
		{% if current_file %}
			profile
		{% else %}
			{% if current_university %}
				notices
			{% else %}
				{% if current_institution %}
					stuw
				{% else %}
					file
				{% endif %}
			{% endif %}
		{% endif %}
	{% endif %}
{% endblock %}

{% block subnav %}
	{% if current_article %}
		<br/>
	{% else %}
		{% if current_file %}
		{% else %}
			{% if current_university %}
				<ul id="submenu">
        			<li><a href="/university/1">{% trans "АНУ/Канад" %}</a></li>
        			<li><a href="/university/2">{% trans "Их Британи/Австрали" %}</a></li>
        			<li><a href="/university/3">{% trans "ЕВРОП" %}</a></li>
        			<li><a href="/university/4">{% trans "AЗИ " %}</a></li>
    			</ul>
    		{% else %}
    			{% if current_institution %}
    				<br />
    				{% else %}
    					{% if current_profile %}
    					<br/>
    					{% endif %}
    			{% endif %}
			{% endif %}
		{% endif %}
	{% endif %}
{% endblock %}

{% block body %}
	
	<div id="mains">
		{% if current_article %}
			<div id="article_detail">
				<h2>{{current_article.header}}</h2>
				<br />
				<img src="../../site_media/media/{{current_article.photo}}" width="602px" height="400px"/>
				<p>{{current_article.content|safe}}</p>
				<br />
				<p>Ангилал: {{current_article.category}}</p>
				<small id = "angilal_delgerengui"><em>Уншсан тоо: {{current_article.read_count}}, {{current_article.pub_date}}</em></small>
				<!-- Place this tag where you want the +1 button to render -->
				<small class="another_class"><g:plusone size="small" annotation="icon"></g:plusone></small>
				<a href="save_article/{{current_article.id}}"><b><div id ="save">Хадгалах</div></b></a>
			</div>
		{% endif %}
		
		{% if current_file %}
			<div id="file_detail">
			
				<img src="../../site_media/media/{{current_file.file_image}}"/>
				<h3  id = "ehlelfile">{{current_file.file_name}}</h3>
				<br />
				<p>Хэмжээ: {{current_file.file.size|filesizeformat}}</p>
				<br />
				<p>{{current_file.file_description}}</p>
				<!-- Place this tag where you want the +1 button to render -->
				<small class="another_class"><g:plusone size="small" annotation="icon"></g:plusone></small>
				<br />
				<a>Файлыг татах</a>
			
			</div>
		{% endif %}
	
		
		{% if current_university %}
			<div id="university_detail">
				{% if current_university.uni_category == 1 %}
					<h3>АНУ/Канадын их, дээд сургууль</h3>
				{% endif %}
			
				{% if current_university.uni_category == 2 %}
					<h3>Их Британи, Австралийн Их, Дээд сургууль</h3>
				{% endif %}
				
				{% if current_university.uni_category == 3 %}
					<h3>Европийн Их, Дээд сургууль</h3>
				{% endif %}
				
				{% if current_university.uni_category == 4 %}
					<h3> Азийн Их, Дээд Сургууль</h3>
				{% endif %}
			
				<img src="../../site_media/media/{{current_university.uni_image}}" width="300px" height="250px"/>
				
				<br />
				<h2>{{current_university.uni_name}}</h2>
				<br />
				<h5>Албан ёсны хаяг</h5>
				<p>{{current_university.uni_address|safe}}</p>
				<br />
				<h5>Сургуулийн тухай</h5>
				<p>{{current_university.uni_about|safe}}</p>
				<br />
				<h5>Хөтөлбөр</h5>
				<p>{{current_university.uni_schedule|safe}}</p>
				<br />
				<h5>Тэтгэлэг</h5>
				<p>{{current_university.uni_scholarship|safe}}</p>
				<br />
				
				<!-- Place this tag where you want the +1 button to render -->
				<small class="another_class"><g:plusone size="small" annotation="icon"></g:plusone></small>
				<a href="save_university/{{current_university.id}}"><b><div id = "save_university1">Хадгалах</div></b></a>
				<div style="float:left; width:99%; margin-left:5px; ">
					<h3>Сургуультай Холбоотой мэдээ</h3>
					{% for article in articles %}
				       	{% if forloop.first %}
											<div id = "first_small_container">
													<div id = "small_pic">
														<a href="/articles/{{article.id}}">
														<img src="../../site_media/media/{{article.photo}}" width="139" height="100"/>
														<p id="small_header">{{article.header}}</p>
														</a>
													</div>
											</div>
										{% else %}
											<div id = "small_container">
													<div id = "small_pic">
														<a href="/articles/{{article.id}}">
															<img src="../../site_media/media/{{article.photo}}" width="139" height="100"/>
														<p id = "small_header">{{article.header}}</p>
														</a>
													</div>
											</div>
									{% endif %}
				   		{% endfor %}
				  </div>
			</div>
		{% endif %}
	</div>
	
		{% if current_institution %}
			<div id="institution_detail">
				{% if banner_top %}
					<div id = "institution_banner">
						<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
						  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
						  id="name" width="728" height="90">
						  <param name="movie" value="../../site_media/media/{{banner_top}}">
						  <param name="quality" value="high">
						  <param name="wmode" value="transparent">
						  <embed name="name" src="../../site_media/media/{{banner_top}}"
							  quality="high" wmode="transparent" width="728" height="90"
							  type="application/x-shockwave-flash" 
							  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
							  P1_Prod_Version=ShockwaveFlash">
						  </embed>
						</object>
					</div>
				{% endif %}
				
				<div id = "inst_garchig">
					<h2 style="float:left; text-align:left;">{{current_institution.ins_name}}</h2>
					<br/>
					<br/>
				</div>
				
				<div id="institution_detail_left">
					<img src="../../site_media/media/{{current_institution.ins_image}}" width="300px" height="250px"/>
					<br />
				</div>
				<div id="institution_detail_right">
					<table width="590">
					<tr><td><p class="left"><b>Албан ёсны хаяг:</b> {{current_institution.ins_address|truncatewords:50|safe}}</p></td></tr>
					<tr><td><p class="left"><b>Вэб сайт:</b> <a href="http://{{current_institution.ins_web}}">{{current_institution.ins_web}}</a></p></td></tr>
					<tr><td><p class="left"><b>Цахим шуудан:</b> {{current_institution.ins_email}}</p></td></tr>
					<tr><td><p class="left"><b>Утас:</b> {{current_institution.ins_phone}}</p></td></tr>
					</table>
					<br />
				</div>
				
				<div id="institution_detail_center">
					<p><b>Танилцуулга: </b>{{current_institution.ins_intro|safe}}</p>
					<br />
					<p><b>Хөтөлбөр: </b>{{current_institution.ins_schedule|safe}}</p>
				</div>
				
				<!-- Place this tag where you want the +1 button to render -->
				<div id = "institutioin_google"><small class="another_class"><g:plusone size="small" annotation="icon"></g:plusone></small></div>
				
				<a href="save_institution/{{current_institution.id}}"><b><div id = "save_institution1">Хадгалах</div></b></a>
			</div>
		{% endif %}
		
		{% if current_profile %}
		
		<div id = "profile_container">
			<div id="profile_detail">
				<table width="100%">
					<tr>
						<td width="35%">
							<div style="width:320px; height:270px;">
								<p id="pro_name">{{current_profile.lastname}} {{current_profile.firstname}}</p>
								<img id="pro_pic" src="../../site_media/media/{{current_profile.image}}" width="140" height="160"/>
								<div id="pro_inf">	
									<p class="usenonly">Элссэн огноо:</p> <p  style="width:128px; float:left;">{{current_profile.joined_date}}</p>
									<p class="usenonly">И-мэйл:</p> <p style="width:128px; float:left;">{{current_profile.user.email}}</p>
									<p class="usenonly">Утас: </p> <p style="width:128px; float:left;">{{current_profile.phone}}</p>
									<p class="usenonly">Мотто: </p> <p style="width:128px;float:left">{{current_profile.motto}}</p>
								</div>
								<p style="float:left; width:260px;"><a href="{% url edit_profile %}">Мэдээлэл шинэчлэх</a></p>
							</div>
						</td>
						
						<td width="65%">
							<div class="titan_div">
								<div class="header_of_titan">
								<h4 id = "exam_history"> Шалгалтын түүх </h4>
								</div>
							</div>
							<div class="titan_div">
								<div class="header_of_titan">
									<h4 id = "need_news">Хэрэгтэй мэдээний жагсаалт</h4>
								</div>
								<ul>
									
										{% for article in saved_articles %}
										
											<div id = "save_article"><a href="/articles/{{article.article_id.id}}"><li>{{article.article_id|truncatewords:3}}</a></div>
											<div id = "save_delete"><a href="/delete_article/{{article.article_id.id}}">Устгах</a></li></div>
																						
										{% endfor %}
									
										{% for university in saved_universities %}
											<div id = "save_university"><a href="/universities/{{university.university_id.id}}"><li>{{university.university_id|truncatewords:3}}</a> </div>
											<div id = "university_delete"><a href="/delete_university/{{university.university_id.id}}">Устгах</a></li> </div>													
										{% endfor %}
										
										{% for institution in saved_institutions %}
											<div id ="save_institution"><a href="/institutions/{{institution.institution_id.id}}"><li>{{institution.institution_id|truncatewords:3}}</a></div>
											<div id = "institution_delete"><a href="/delete_institution/{{institution.institution_id.id}}">Устгах</a></li></div>													
										{% endfor %}
									
									</ul>
									{% if error %}
										<div id ="medeenii_aldaa"><p>{{error}}</p></div>
									{% endif %}
							</div>
						</td>
						
						
					</tr>
					<tr>
						<td colspan="2">
						<div id="inf_medees">
						<h3>Сүүлд уншсан мэдээ</h3>
						<br/>
							<ul>
									{% for article in read_articles %}
									<li>
										<div id="small_container">
											<img src="../../site_media/media/{{article.article_id.photo}}" width="135" height="100"/>
											<a href="/articles/{{article.article_id.id}}"><h2 class="abswid">{{article.article_id.header|truncatewords:2}}</h2></a>
										</div>
									</li>
									{% endfor %}
									
									{% for university in read_universities %}
									<li>
										<div id="small_container">
											<img src="../../site_media/media/{{university.university_id.uni_image}}" width="135" height="100"/>
											<a href="/universities/{{university.university_id.id}}"><h2 class="abswid">{{university.university_id|truncatewords:2}}</h2></a>
										</div>
									</li>
									{% endfor %}
									
									{% for institution in read_institutions %}
									<li>
										<div id="small_container">
											<img src="../../site_media/media/{{institution.institution_id.ins_image}}" width="135" height="100"/>
											<a href="/institutions/{{institution.institution_id.id}}"><h2 class="abswid">{{institution.institution_id|truncatewords:2}}</h2></a>
										</div>
									</li>
									{% endfor %}
							</ul>
						</div>
					</td>
					</tr>
					
					<tr>
						{% if banner_bottom %}
							<td colspan="2" style=" height:100px; border-style:solid; border-width:1px">
							<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
							  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
							  id="name" width="728" height="90">
							  <param name="movie" value="../../site_media/media/{{banner_bottom}}">
							  <param name="quality" value="high">
							  <param name="wmode" value="transparent">
							  <embed name="name" src="../../site_media/media/{{banner_bottom}}"
								  quality="high" wmode="transparent" width="728" height="90"
								  type="application/x-shockwave-flash" 
								  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
								  P1_Prod_Version=ShockwaveFlash">
							  </embed>
							</object>
							</td>
						{% endif %}
					</tr>
				</table>
			</div>
				
			</div>
		
		{% endif %}
	
	{% if not current_file %}
		{% if not current_university %}
			{% if not current_institution %}
				{% if not current_profile %}
					<div id= "smedee">
						<h3>Шинэ мэдээ </h3>
						{% for article in articles %}
							<ul>
					        	<li>
					            	<div class="blocksss">
					               		<h4><a href="/articles/{{article.id}}">{{article.header}}</a></h4>
					                	<p>{{article.content|truncatewords:20|safe}}</p>
					                	<small>Уншсан тоо: {{article.read_count}} | {{article.pub_date}} | <a class="del_news" href="/articles/{{article.id}}""> Дэлгэрэнгүй </a></small>
					            	</div>
					        	</li>
					       </ul>
				    	{% endfor %}
				     
				    	{% if not current_institution %}
				    		<div id="categories">
								<h3>Мэдээний ангилал</h3>
								{% for category in categories %}
									<a href="/categories/{{category.id}}">{{category.category}} / </a>
								{% endfor %}
							</div>
						{% endif %}
						{% if banner_right_short %}
				    		<div id="Banner_Center">
								<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
								  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
								  id="name" width="287" height="250">
								  <param name="movie" value="../../site_media/media/{{banner_right_short}}">
								  <param name="quality" value="high">
								  <param name="wmode" value="transparent">
								  <embed name="name" src="../../site_media/media/{{banner_right_short}}"
									  quality="high" wmode="transparent" width="287" height="250"
									  type="application/x-shockwave-flash" 
									  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
									  P1_Prod_Version=ShockwaveFlash">
								  </embed>
								</object>
							</div>
						{% endif %}
					</div>
				{%endif%}		
			{%endif%}
		{% endif %}	
	{% endif %}
	
	{% if current_institution %}
	<div style="float:left; width:99%; margin-left:5px; ">
		<h3>Холбоотой мэдээ</h3>
		{% for article in articles %}
	       	{% if forloop.first %}
								<div id = "first_small_container">
										<div id = "small_pic">
											<a href="/articles/{{article.id}}">
											<img src="../../site_media/media/{{article.photo}}" width="140" height="100"/>
											<p id="small_header">{{article.header}}</p>
											</a>
										</div>
								</div>
							{% else %}
								<div id = "small_container">
										<div id = "small_pic">
											<a href="/articles/{{article.id}}">
												<img src="../../site_media/media/{{article.photo}}" width="140" height="100"/>
											<p id = "small_header">{{article.header}}</p>
											</a>
										</div>
								</div>
						{% endif %}
	   		{% endfor %}
	  </div>
	{% endif %}
		
	
	{% if current_university%}
		{% if banner_right_long %}
			<div id="del_banner">
				<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
				  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
				  id="name" width="160" height="600">
				  <param name="movie" value="../../site_media/media/{{banner_right_long}}">
				  <param name="quality" value="high">
				  <param name="wmode" value="transparent">
				  <embed name="name" src="../../site_media/media/{{banner_right_long}}"
					  quality="high" wmode="transparent" width="160" height="600"
					  type="application/x-shockwave-flash" 
					  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
					  P1_Prod_Version=ShockwaveFlash">
				  </embed>
				</object>
			</div>
		{% endif %}
	{% endif %}
	
	{% if current_article %}
		<div id="comments">
		<table>
			<tr>
				<td><h3>Сэтгэгдэл </h3></td>
			</tr>
			<tr>
				<td><form action="{% url toefl_app.views.add_article_comment current_article.id %}" method="POST">
					{% csrf_token %}
					<p class="left"><b>Нэр:</b> {{ user.username }} </p><br/>
					<p class="left"><b >Сэтгэгдэл:</b><br/>{{ form.body}} </p><br/>
					<input style="float:left;" type="submit" value="Сэтгэгдэл үлдээх"/>
				</form></td>
			</tr>
			{% if comments %}
				<tr><td><p>Сэтгэгдлүүд:</p></td></tr>
			{% endif %}
			
			{% for comment in comments %}
				<tr><td>
						<div id="comment">
						<p id="comment_name"><small>Эрхэм {{ comment.author }} нь {{ comment.created|date:"Y/m/d H:i:s" }}-д энэ сэтгэгдлийг үлдээв</small>
							<!-- Place this tag where you want the +1 button to render -->
							<small class="another_class_comment"><g:plusone size="small" annotation="icon"></g:plusone></small>
						</p>
						<p id="comment_value"> {{ comment.body}} </p>
						</div>
					</td>
				</tr>
			{% endfor %}
			</table>
		</div>
	{% endif %}
	
	{% if current_file %}
		<div id="comments">			
			<table>
			<tr>
				<td><h3>Сэтгэгдэл </h3></td>
			</tr>
			<tr>
				<td><form action="{% url toefl_app.views.add_file_comment current_file.id %}" method="POST">
					{% csrf_token %}
					<p class="left"><b>Нэр:</b> {{ user.username }} </p><br/>
					<p class="left"><b >Сэтгэгдэл:</b><br/>{{ form.body}} </p><br/>
					<input style="float:left;" type="submit" value="Сэтгэгдэл үлдээх"/>
				</form></td>
			</tr>
			{% if comments %}
				<tr><td><p>Сэтгэгдлүүд:</p></td></tr>
			{% endif %}
			
			{% for comment in comments %}
				<tr><td>
						<div id="comment">
						<p id="comment_name"><small>Эрхэм {{ comment.author }} нь {{ comment.created|date:"Y/m/d H:i:s" }}-д энэ сэтгэгдлийг үлдээв</small>
							<!-- Place this tag where you want the +1 button to render -->
							<small class="another_class_comment"><g:plusone size="small" annotation="icon"></g:plusone></small>
						</p>
						<p id="comment_value"> {{ comment.body}} </p>
						</div>
					</td>
				</tr>
			{% endfor %}
			</table>
		</div>
	{% endif %}
	
	{% if current_university %}
		<div id="comments">	
			<table>
			<tr>
				<td><h3>Сэтгэгдэл </h3></td>
			</tr>
			<tr>
				<td><form action="{% url toefl_app.views.add_university_comment current_university.id %}" method="POST">
					{% csrf_token %}
					<p class="left"><b>Нэр:</b> {{ user.username }} </p><br/>
					<p class="left"><b >Сэтгэгдэл:</b><br/>{{ form.body}} </p><br/>
					<input style="float:left;" type="submit" value="Сэтгэгдэл үлдээх"/>
				</form></td>
			</tr>
			{% if comments %}
				<tr><td><p>Сэтгэгдлүүд:</p></td></tr>
			{% endif %}
			
			{% for comment in comments %}
				<tr><td>
						<div id="comment">
						<p id="comment_name"><small>Эрхэм {{ comment.author }} нь {{ comment.created|date:"Y/m/d H:i:s" }}-д энэ сэтгэгдлийг үлдээв</small>
							<!-- Place this tag where you want the +1 button to render -->
							<small class="another_class_comment"><g:plusone size="small" annotation="icon"></g:plusone></small>
						</p>
						<p id="comment_value"> {{ comment.body}} </p>
						</div>
					</td>
				</tr>
			{% endfor %}
			</table>
		</div>
	{% endif %}
	
	{% if current_institution %}
		<div id="commentss">
			<table width="902">
			<tr>
				<td><h3>Сэтгэгдэл </h3></td>
			</tr>
			<tr>
				<td><form action="{% url toefl_app.views.add_institution_comment current_institution.id %}" method="POST">
					{% csrf_token %}
					<tr><td><p class="left"><b>Нэр:</b> {{ user.username }} </p><br/></td></tr>
					<tr><td><p class="left"><b >Сэтгэгдэл:</b><br/>{{ form.body}} </p><br/></td></tr>
					<tr><td><input style="float:left;" type="submit" value="Сэтгэгдэл үлдээх"/></td></tr>
				</form></td>
			</tr>
			{% if comments %}
				<tr><td><p>Сэтгэгдлүүд:</p></td></tr>
			{% endif %}
			
			{% for comment in comments %}
				<tr><td>
						<div id="comment">
						<p id="comment_name"><small>Эрхэм {{ comment.author }} нь {{ comment.created|date:"Y/m/d H:i:s" }}-д энэ сэтгэгдлийг үлдээв</small>
							<!-- Place this tag where you want the +1 button to render -->
							<small class="another_class_comment"><g:plusone size="small" annotation="icon"></g:plusone></small>
						</p>
						<p id="comment_value"> {{ comment.body}} </p>
						</div>
					</td>
				</tr>
			{% endfor %}
			</table>
		</div>
	{% endif %}


{% endblock %}
